var c = document.getElementById('c');
var ctx = c.getContext('2d');

ctx.save();
ctx.fillStyle = '#ddd';
ctx.fillRect(0, 0, c.width, c.height);
ctx.translate(c.width / 2, c.height / 2);
ctx.rotate(90 * Math.PI / 180);

var allPoints = PolygonAndPolyhorns(0, 0, 50, 3, 'polygon');

ctx.strokeStyle = '#222';
ctx.beginPath();
ctx.moveTo(allPoints[0].x, allPoints[0].y);
for(var i = 1; i < allPoints.length; i += 1) {
    ctx.lineTo(allPoints[i].x, allPoints[i].y);
}
ctx.closePath();
ctx.stroke();
ctx.restore();

ctx.save();
ctx.translate(c.width / 2, c.height / 2);
ctx.scale(-1, 1); //绘制镜像（水平），scale(1, -1)竖直方向
ctx.rotate(90 * Math.PI / 180);
var allPoints = PolygonAndPolyhorns(0, 0, 50, 3, 'polygon');

ctx.strokeStyle = '#222';
ctx.beginPath();
ctx.moveTo(allPoints[0].x, allPoints[0].y);
for(var i = 1; i < allPoints.length; i += 1) {
    ctx.lineTo(allPoints[i].x, allPoints[i].y);
}
ctx.closePath();
ctx.stroke();
ctx.restore();